package com.gsit.job.flows;

import org.springframework.stereotype.Component;

import com.gsit.job.config.Config;
import com.gsit.job.domain.Person;

@Component
public class LoadAndWriteResume extends BaseFlow {

	Integer startIndex;
	
	@Override
	protected void process() throws Exception {
		
		startIndex= personService.findAll().size()+Config.START_OFF_SET;
		for (int index = startIndex; index < (startIndex+Config.LIMMIT); index++) {
			loadPage(index );
		}

	}
	
	
	private void loadPage(int index){
		driver.get(Config.RESUME_URL+index+"&offset=");
		Person person = parser.parseData(driver);
		person.setResid(""+index);
		personService.saveOrUpdate(person);
		System.out.println("person >>>"+person.toString());
		fileWriter.write(person, driver.getPageSource());
	}
	
	
	
	

}
